//
//  XQChartView.h
//  XQChartDemo
//
//  Created by xq on 2024/6/15.
//

#import <UIKit/UIKit.h>

NS_ASSUME_NONNULL_BEGIN

@class XQChartView;

@protocol XQChartViewDelegate <NSObject>

/// 已加载view，很多操作要在加载完成之后再进行
- (void)xqChartViewDidFinishLoad:(XQChartView *)xqChartView;

/// 取消/选择 某个点
- (void)xqChartView:(XQChartView *)xqChartView index:(NSUInteger)index point:(CGPoint)point select:(BOOL)select;

@end

@interface XQChartView : UIView

@property (nonatomic, weak) id<XQChartViewDelegate> delegate;

/// 已选点颜色
/// @"#FFFFFF" 十六进制颜色，其他颜色也相同
@property (nonatomic, copy) NSString *selectPointColor;

/// 未选点颜色
@property (nonatomic, copy) NSString *unselectPointColor;

/// 线颜色
@property (nonatomic, copy) NSString *lineColor;

/// 背景颜色
@property (nonatomic, copy) NSString *chartBackgroundColor;

/// 是否显示x轴
@property (nonatomic, assign) BOOL xAxisVisible;

/// 是否显示y轴
@property (nonatomic, assign) BOOL yAxisVisible;

/// 点, CGPoint
@property (nonatomic, strong) NSMutableArray *points;

/// 最小值
@property (nonatomic, assign) CGFloat minY;

/// 最大值
@property (nonatomic, assign) CGFloat maxY;

@property (nonatomic, assign) CGFloat overflowY;

/// 最小值
@property (nonatomic, assign) CGFloat minX;

/// 最大值
@property (nonatomic, assign) CGFloat maxX;

@property (nonatomic, assign) CGFloat overflowX;

/// 重新渲染
- (void)drawChartModel;
- (void)drawChartModelWithRefresh:(BOOL)refresh;
- (void)drawChartModelWithSeries:(NSArray *)series refresh:(BOOL)refresh;

/// 更新点位置
/// @param points Y的值 @[@10.2, @2.3]
- (void)refreshWithPoints:(NSArray *)points;

/// 更新点位置
/// @param points CGPoint类型
/// @param selectIndex 选中哪个
- (void)refreshWithPoints:(NSArray *)points selectIndex:(NSUInteger)selectIndex;

/// 添加点
- (void)addPointWithPoint:(CGPoint)point;

/// 自动根据当前情况添加点
- (void)autoAddPoint;

/// 删除选中点
- (void)removeSelectPoint;

/// 改变选中的点 point 的 xy
- (BOOL)changeSelectPointXY:(CGPoint)xy;

/// 选中上一个点
- (void)selectPrePoint;

/// 选中下一个点
- (void)selectNextPoint;

@end

NS_ASSUME_NONNULL_END
